<template>
  <el-dialog :title="'详细信息'" :close-on-click-modal="false" :visible.sync="visible" :append-to-body="true">
    <template>
      <el-form :inline="true" :model="dataForm" class="demo-form-inline">
        <el-form-item>
          <el-button type="primary" @click="getInfo">查询</el-button>
        </el-form-item>
      </el-form>

      <el-table :data="shopList" v-loading="dataListLoading" style="width: 100%" :default-sort="{prop: 'date', order: 'descending'}">
        <el-table-column prop="conNameTwo" label="科目" sortable width="150">
        </el-table-column>
        <el-table-column prop="conNameOne" label="分类" sortable width="150">
        </el-table-column>
        <el-table-column prop="shopname" label="名称" width="150">
        </el-table-column>
        <el-table-column prop="shopPrice" label="单价" sortable width="150">
        </el-table-column>
        <el-table-column prop="buyNumber" label="数量" sortable width="150">
        </el-table-column>
        <el-table-column prop="buyPeopleName" label="购买人" width="180">
        </el-table-column>
        <el-table-column label="总价格" sortable width="150">
          <template slot-scope="scope">
            <span>{{(scope.row.shopPrice * scope.row.buyNumber).toFixed(2)}}</span>
          </template>
        </el-table-column>
<!--        <el-table-column prop="kedanremake" label="备注" sortable width="180">
          <template slot-scope="scope">
            <el-input v-model="scope.row.kedanremake" @change="updateshopByc(scope.row)" placeholder="客单备注"></el-input>
          </template>
        </el-table-column> -->
        <el-table-column prop="username" label="操作人" width="180">
          <template slot-scope="scope">
            <span>{{scope.row.username ? scope.row.username : '--'}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="accRemarks" label="备注" width="180">
          <template slot-scope="scope">
            <span>{{scope.row.accRemarks ? scope.row.accRemarks : '--'}}</span>
          </template>
        </el-table-column>
        <!--           <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
             <template slot-scope="scope" v-if="scope.row.payType!=9&&scope.row.payType!=20">
               <el-button type="text" size="small" v-if="scope.row.type == 2" @click="revokeTransferBtn(scope.row)">撤销转账</el-button>
               <el-popover placement="left" width="80" trigger="hover">
                 <dl class="dl_drop">
                   <dd v-if="scope.row.type == 0" @click="closingsBtn(scope.row)">结账</dd>
                   <dd v-if="scope.row.type == 0" @click="transferaccountssBtn(scope.row)">转账</dd>
                   <dd v-if="scope.row.type == 0" @click="demolitionBtn(scope.row)">拆账</dd>
                   <dd v-if="scope.row.payType == 2 && scope.row.type == 0" @click="returnGoods(scope.row.id)">退货</dd>
                 </dl>
                 <el-button type="text" size="small" slot="reference"><i class="el-icon-more" title="更多" id="printMenu"></i></el-button>
               </el-popover>
             </template>
           </el-table-column> -->
      </el-table>
      <el-pagination
      style="text-align: right;margin-top: 10px;"
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper"
      ></el-pagination>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="visible = false">关 闭</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        dataListLoading: false,
        visible: false,
        dataForm: {
          id: 0,
          remarks: ''
        },

        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        shopList:[]
      };
    },

    components: {

    },
    methods: {
      init(id) {
        this.visible = true;
        this.dataForm.id = id;
        this.$nextTick(() => {
          this.getInfo()
        });
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val;
        this.pageIndex = 1;
        this.getInfo();
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val;
        this.getInfo();
      },
      getInfo() {
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelfloorroomcheckinaccounting/commodityRecords`),
          method: 'get',
          params: this.$http.adornParams({
            page: this.pageIndex,
            limit: this.pageSize,
            accountId: this.dataForm.id
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.shopList = data.page.list
            this.totalPage = data.page.totalCount;
          } else {
            this.$message.error(data.msg);
          }
        });
      },
    }
  };
</script>

<style lang="scss" scoped>

  .el-dialog__wrapper /deep/ .el-dialog {
    width: 70%;

    .el-footer {
      padding-right: 0;
    }

    /deep/ .el-aside {
      white-space: nowrap;
    }
  }

  @media only screen and (max-width: 1180px) {
    .el-dialog__wrapper /deep/ .el-dialog {
      width: 100%;
    }
  }
</style>
